import path from "path";

// 配置环境变量
import dotenv from "dotenv";
dotenv.config();
import express from "express";
import session from "express-session";

// 捕获异步错误
import "express-async-errors";

// 初始化数据库
import "./dao/db/index";

// 创建路由
import { createRouter } from "./routes/index";
const app = express();
app.use(express.json());
app.use("/", express.static(path.join(__dirname, "../public")));

app.use(
  session({
    secret: "wieujflskjdfhokk",
  })
);
createRouter(app);

// 启动服务
app.listen(process.env.Y_APP_PORT, () => {
  console.log(`监听${process.env.Y_APP_PORT}端口中...`);
});
